const mongoose = require('mongoose');
const Schema = mongoose.Schema;

let ObjectId = Schema.Types.ObjectId;

/*
*  model，即一个对象的具体结构，这些字段也将写进数据库
* */

// 创建userSchema
const userSchema = new Schema({
  userId: {type: ObjectId},
  userName: {type: String, required: true, unique: true},// unique表示唯一 不重复
  avatar: {type: String},
  password: {type: String, required: true},
  createTime: {type: Date, default: Date.now()},// default表示默认值
  gender: {type: String},
  birthday: {type: Date},
});

// 发布model模型 这里的user对应数据库中的集合
const User = mongoose.model("users", userSchema);
module.exports = User;
